/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.config.javabeans;

import java.util.ArrayList;
import java.util.List;


/**
 * Class corresponding to the "levelRessource" element of the views.xml file.
 */
public class JBLevelRessource implements java.io.Serializable
{
    /** Name of the LevelRessource. */
    private String name;

    /** Value of the LevelRessource in case it is a single object. */
    private String value;

    /** Case when the LevelRessource depends on other LevelRessources. */
    private String depends;

    /** objectview name. */
    private String objectview;

    /** Optional type, currently only "leaf" is allowed. */
    private String type;

    /** Link criteria list. */
    private List linkList = new ArrayList();

    /** Creates new JBLevelRessource. */
    public JBLevelRessource()
    {
    }

    /**
     * Returns the linkList.
     * @return List
     */
    public List getLinkList()
    {
        return linkList;
    }

    /**
     * Adds a link.
     *
     * @param link link to add
     */
    public void addLink(JBLink link)
    {
        this.linkList.add(link);
    }

    /**
     * Displays the LevelRessource.
     *
     * @return String representation of the LevelRessource.
     */
    @Override
	public String toString()
    {
        StringBuffer buf = new StringBuffer();
        java.util.Iterator it = null;

        buf.append("      value = ");
        buf.append(name);
        buf.append(System.getProperty("line.separator"));

        if (linkList != null)
        {
            buf.append("      List components of levelRessourceList = ");
            buf.append(System.getProperty("line.separator"));
            it = linkList.iterator();

            while (it.hasNext())
            {
                buf.append("      ...");
                buf.append(it.next());
                buf.append(System.getProperty("line.separator"));
            }
        }

        return buf.toString();
    }

    // end of toString method

    /**
     * Returns the name of the LevelRessource.
     * @return String
     */
    public String getName()
    {
        return name;
    }

    /**
     * Sets the name of the LevelRessource.
     * @param aname The name to set
     */
    public void setName(String aname)
    {
        this.name = aname;
    }

    /**
     * Returns the value, in case the LevelRessource corresponds to a single entry.
     * @return String
     */
    public String getValue()
    {
        return value;
    }

    /**
     * Sets the value, in case the LevelRessource corresponds to a single entry.
     * @param avalue The value to set
     */
    public void setValue(String avalue)
    {
        this.value = avalue;
    }

    /**
     * Gets the depends: case when the LevelRessource depends of LevelRessources of other levels.
     * @return Returns the depends.
     */
    public String getDepends()
    {
        return depends;
    }

    /**
     * Sets the depends: case when the LevelRessource depends of LevelRessources of other levels.
     * @param adepends The depends to set.
     */
    public void setDepends(String adepends)
    {
        this.depends = adepends;
    }

    /**
     * Sets the name of the associated objectview.
     * @return Returns the objectview.
     */
    public String getObjectview()
    {
        return objectview;
    }

    /**
     * Gets the name of the associated objectview.
     * @param aobjectview The objectview to set.
     */
    public void setObjectview(String aobjectview)
    {
        this.objectview = aobjectview;
    }

    /**
     * Returns the optional type: currently only "leaf" is allowed.
     * @return the type.
     */
    public String getType()
    {
        return type;
    }

    /**
     * Sets the the optional type: currently only "leaf" is allowed.
     * @param atype The type to set.
     */
    public void setType(String atype)
    {
        this.type = atype;
    }
}
